namespace Vin.Tool.Core.EnvironmentCategory;

public class EnvironmentTool
{
    /// <summary>
    /// 获取当前进程的路径
    /// </summary>
    public static string ProcessPath => Environment.ProcessPath ?? string.Empty;

    /// <summary>
    /// 获取当前进程的名称
    /// </summary>
    public static string ProcessName =>
        Environment.ProcessPath?.Split(Path.DirectorySeparatorChar).LastOrDefault() ?? string.Empty;

    /// <summary>
    /// 获取当前进程的目录
    /// </summary>
    public static string ProcessDirectory => Path.GetDirectoryName(Environment.ProcessPath) ?? string.Empty;

    /// <summary>
    /// 获取当前进程的相对目录
    /// </summary>
    public static string GetRelativeProcessDirectory(string relativePath) =>
        OperatingSystem.IsLinux()
            ? relativePath
            : string.IsNullOrEmpty(relativePath)
                ? ProcessDirectory
                : Path.Join(ProcessDirectory, relativePath);

    /// <summary>
    /// 获取当前工作目录
    /// </summary>
    public static string CurrentDirectory => Environment.CurrentDirectory;
}